<!DOCTYPE html>
<html lang="zh">

<head>
  <title></title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://unpkg.com/vue/dist/vue.js"></script>
  <link href="../css/style.css" rel="stylesheet">
</head>

<body>
  <div id="myApp">
    <ol>
      <game-item v-for="item in games" v-bind:game="item"></game-item>
    </ol>
  </div>
  <script>
    /* 组件定义：game-item ，全局注册组件*/
    Vue.component('game-item', {
      props: ['game'],
      template: '<li>{{ game.title }}</li>',
      // template: '<li>{{ game.title }} --- {{name}}</li>',
      // data: function () {
      //   return {
      //     name: '子组件张三',
      //   }
      // }
    });
    /* Vue对象实例化 */
    var myApp = new Vue({
      el: '#myApp',
      data: {
        games: [
          { title: '斗地主' },
          { title: '打麻雀' },
          { title: 'UNO' }
        ]
      }
    });
  </script>
</body>

</html>